package com.kwlt.smc.dao;

import java.util.List;

import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;

import com.kwlt.smc.entity.Channel;
import com.kwlt.smc.entity.UserChannel;



public interface UserChannelDao  extends PagingAndSortingRepository<UserChannel,Long>{
	@Query("select c,u.weight from UserChannel u,Channel c,User a where c.status = 'A' and u.channelId = c.channelId and u.userId =a.userId and a.status = 'A' and a.loginName = :loginName")
	List getUserChannel(@Param("loginName")String loginName);
	
	
	@Query("select c from UserChannel u,Channel c,User a where u.channelId = c.channelId and u.userId =a.userId and a.status = 'A' and a.loginName = :loginName")
	List<Channel> getChannelByLoginName(@Param("loginName")String loginName);
	
	@Query("select c from UserChannel u,Channel c,User a where u.channelId = c.channelId and u.userId =a.userId and a.loginName = :loginName and c.operators= :operators")
	List<Channel> getUserChannelForOperators(@Param("loginName")String loginName, @Param("operators")String operators);
}
